<?php
/**
 * 判定语言中间件
 * Created by PhpStorm.
 * User: geyouwen
 * Date: 17/2/6
 * Time: 上午9:31
 */

namespace App\Http\Middleware;


use Closure;

class LangMiddleware
{
    public function handle($request, Closure $next)
    {
        //从参数中获取lang
        $lang = isset($request->all()['lang']) ? strtolower($request->all()['lang']) : env('APP_LANG');

        //从头部cookie获取lang
//        $lang =  $request->cookie('LANG') ? $request->cookie('LANG') : env('APP_LANG');
        $request->lang = $lang;
        return $next($request);
    }
}